using Jupiter;
using Jupiter.Infrastructure.Permission.DataPermissions;
using System.Reflection;
using System.Text;
using Wips.Infrastructure;
using Wips.Infrastructure.Middlewares;

var builder = WebApplication.CreateBuilder(args);
var services = builder.Services;
var configuration = builder.Configuration;
var env = builder.Environment;
Assembly[] assemblies =
{
    typeof(Wips.AgentServer.Anchor).Assembly

};
Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);
services.AddJupiter<Wips.AgentServer.Anchor>(
    configuration,
    assemblies.ToList()
);
services.AddPublishAgent(); // 注册发布子服务
services.AddSingleton<IDataPermission, BlankPermissions>();
var app = builder.Build();
if (env.IsDevelopment())
{
    app.UseDeveloperExceptionPage();
}

app.UseJupiter<Wips.AgentServer.Anchor>(configuration, assemblies);
app.UsePublishAgent(); // use 发布子服务
app.MapAgentSever(); // 注册子服务
app.UseMiddleware<Rsa2Middleware>(); // 使用校验中间件
app.Run();